/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package GraphicModels;

import gleem.linalg.Vec3f;
import javax.media.opengl.GL;

/**
 * Classe do modelo 3d. Nela sao definidos os valores iniciais de rotacao e escala.
 * @author Gustavo Buzogany Eboli
 */
public class Model {

    private GLModel graphicModel;
    Vec3f scale;
    Vec3f initialRotation;

    /**
     * Construtor do modelo
     */
    public Model()
    {
        this.graphicModel = null;
        this.scale = new Vec3f(1,1,1);
        this.initialRotation = new Vec3f(0,0,0);
    }

    public final void setScale(float x, float y, float z) {
        this.scale = new Vec3f(x, y, z);
    }

    public final void setInitialRotation(float x, float y, float z) {
        this.initialRotation = new Vec3f(x, y, z);
    }

    public final void setScale(Vec3f scale) {
        this.scale = scale.copy();
    }

    public final void setInitialRotation(Vec3f rot) {
        this.initialRotation = rot.copy();
    }

    /**
     * Desenha o modelo
     * @param gl
     */
    public void draw(GL gl)
    {
        gl.glPushMatrix();
        gl.glScalef(scale.x(), scale.y(), scale.z());
        
        gl.glRotatef(initialRotation.x(), 1.0f, 0, 0);
        gl.glRotatef(initialRotation.y(), 0, 1.0f, 0);
        gl.glRotatef(initialRotation.z(), 0, 0, 1.0f);

        
        graphicModel.draw(gl);
        gl.glPopMatrix();
    }

    void setGLModel(GLModel model) {
        this.graphicModel = model;
    }
}
